#ifdef __cplusplus
extern "C" {
#endif

#include <stdlib.h>      // for exit()
#include <unistd.h>      // for sleep()
#include <stdio.h>
#include <pthread.h>

#include "main_core.h"
#include "thread.h"

char Server_file_path[64];  // Path for the server to receive files
char Client_file_path[64];  // Path for the client to send files

int main_core() {
    int ret;

    // Prompt the user to enter file paths
    printf("请输入客户端要发送的文件路径: ");
    scanf("%63s", Client_file_path);  // Limit input size to avoid buffer overflow
    printf("请输入服务端接收文件的路径: ");
    scanf("%63s", Server_file_path);  // Limit input size to avoid buffer overflow

    // 1. Initialize semaphore (optional, can be added here if needed)

    // 2. Create threads to handle the tasks
    ret = thread_create();
    if (ret != 0) {
        perror("创建线程失败");
        return ret;  // Early return on error
    }

    // 3. Wait for all threads to finish
    thread_wait();

    printf("所有线程执行完毕。\n");

    return 0;
}

#ifdef __cplusplus
}
#endif
